import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'

// 导入各个模块
import app from './modules/app'
import user from './modules/user'
import permission from './modules/permission'
import settings from './modules/settings'
import tagsView from './modules/tagsView'

// 导入持久化插件
import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

const store = new Vuex.Store({
    modules: {
        app,
        user,
        permission,
        settings,
        tagsView
    },
    getters,
    // 配置持久化
    plugins: [
        createPersistedState({
            key: 'mall-vuex',
            paths: ['user.token', 'settings', 'app.sidebar', 'app.size'] // 只持久化特定数据
        })
    ]
})

export default store 